<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateTableShopMonitorData extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('shop_monitor_data', function (Blueprint $table) {
            $table->id();
            $table->unsignedInteger("shopId")->default(0)->comment("店铺id");
            $table->unsignedInteger("monitorId")->default(0)->comment("监控设备/温度设备id");
            $table->unsignedTinyInteger("type")->default(0)->comment("类型 0:秒秒测，1:进店，2:过店");
            $table->unsignedInteger("dataAt")->default(0)->comment("记录数据时间");
            $table->unsignedInteger("count")->default(0)->comment("人流量");
            $table->decimal("temperature", 4, 2)->default(0)->comment("温度");
            $table->unsignedInteger('createdAt')->default(0)->comment('创建时间');
            $table->unsignedInteger('updatedAt')->default(0)->comment('更新时间');
            $table->unsignedInteger('createdByUid')->default(0)->comment('创建人');
            $table->unsignedInteger('updatedByUid')->default(0)->comment('更新人');
            $table->index(["shopId", "monitorId"], "shopMonitorIdIdx");
            $table->collation = 'utf8mb4_general_ci';
        });

        $prefix = config('other.DB_PREFIX', '');
        \Illuminate\Support\Facades\DB::statement("ALTER TABLE `{$prefix}shop_monitor_data` COMMENT = '商家监控和温度秒秒测记录表'"); //表注释
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('shop_monitor_data');
    }
}
